﻿#pragma once


//#include "wx/aui/aui.h"

class MainApp : public wxApp
{
public:
	bool OnInit();
};

DECLARE_APP(MainApp)


//处理界面，包括
//清理chart，添加元素，更新状态栏，

class UserEvent: public wxEvent
{
public:
    UserEvent(wxEventType eventType)
        : wxEvent(0, eventType)
    {

    }
    // accessors
	//状态栏用
	wxString msgg;
	
	Point p1,p2;
	//传指针较快
	std::vector<Point*>*red,*blue;

    // implement the base class pure virtual
    virtual wxEvent *Clone() const { return new UserEvent(*this); }
};

class MainFrame : public wxFrame
{
	enum
	{
		ID_TB_START = wxID_HIGHEST+1,
		//ID_TB_PAUSE,
		//ID_TB_STOP,

		ID_CreatePerspective,

		ID_FirstPerspective = ID_CreatePerspective+1000
	};

public:
	MainFrame(wxWindow* parent,
		wxWindowID id,
		const wxString& title,
		const wxPoint& pos = wxDefaultPosition,
		const wxSize& size = wxDefaultSize,
		long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);

	~MainFrame()
	{
		delete wxLog::GetActiveTarget();
	}

public:
	wxString queryPara;
	int comM,comR;//0 base
	void clearChart();
	void addRed(double x,double y);
	void addBlue(double x,double y);
	void addData(std::vector<Point*>&red,std::vector<Point*>&blue);
	void Log2(const wxString&msgs );
	void Log3(const wxString&msgs );

private:
	//初始化时调用
	inline void init_res()
	{
		this->SetIcon(wxICON(mainAppIcon));

		wxXmlResource::Get()->InitAllHandlers();
		if (!wxXmlResource::Get()->Load(wxT(XRC_PATH)) )
			msg(_T("找不到资源文件，请重新安装程序"),TITLE);
		
	}
private:
	void onStart(wxCommandEvent&e);
	void onPause(wxCommandEvent&e);
	void onStop(wxCommandEvent&e);
	void onExit(wxCommandEvent&e);
	void onHelp(wxCommandEvent&e);
	void onAbout(wxCommandEvent&e);
	void onSave(wxCommandEvent&e);
	void onDebug(wxCommandEvent&e);
	void onPort(wxCommandEvent&e);
	//
	void clearChart(UserEvent&e);
	void addRed(UserEvent&e);
	void addBlue(UserEvent&e);
	void addData(UserEvent&e);
	void UpdateStatus2(UserEvent&e);
	void UpdateStatus3(UserEvent&e);
	//
	void setupIni();
	//
	//void setupUserInterfaces(devices&dd);
private:
	chart*plot;
	devices dev;
	wxLogWindow *logw;
	//debug use only
	bool debugMode;
	inisetter ini;
private:
	//数据
	enum
	{
		state_run=1,
		state_pause,
		state_stop
	};
	int state;//由界面控制


	DECLARE_EVENT_TABLE()
};





